package org.wangchaocheng.cloudgallery.config.minio;

import javax.annotation.Resource;

import io.minio.MinioClient;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Minio配置类
 *
 * @author wangchaocheng
 * @date 2025/02/20
 */
@Configuration
public class MinioConfig {

    @Resource
    private MinioConfigurationProperties minioConfigProperties;

    @Bean
    @ConditionalOnProperty(prefix = "minio", name = "enable", havingValue = "true")
    public MinioClient minioClient() {
        return MinioClient.builder()
            .endpoint(minioConfigProperties.getEndpoint())
            .credentials(minioConfigProperties.getAccessKey(), minioConfigProperties.getSecretKey())
            .build();
    }

}
